package com.io.testClone;

import cn.hutool.core.clone.Cloneable;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author keyer
 * @Description : 描述
 * Created by cyd on 2021-04-15 17:18:21
 */
public class TestClone {
    public static void main(String[] args) {
        Dog jack = new Dog(10, "jack", new Object());
        Dog dog2 = jack.clone();
        System.out.println(jack == dog2);
        System.out.println(jack.hashCode() == dog2.hashCode());
    }
}

@Data
@AllArgsConstructor
class Dog implements Cloneable<Dog> {

    int age;
    String name;
    Object master;

    /**
     * 克隆当前对象，浅复制
     *
     * @return 克隆后的对象
     */
    @Override
    public Dog clone() {

        return this;
    }
}

class Person {

}
